#pragma once

#include <gl/glew.h>

#include "../matrixmath.h"

namespace Primitives{
namespace{
    void DrawCube(float scale){
        glScalef(scale, scale, scale);
        glBegin(GL_QUADS);
        //face in xy plane
        glVertex3f(-1,-1, 1);
        glVertex3f( 1,-1, 1);
        glVertex3f( 1, 1, 1);
        glVertex3f(-1, 1, 1);

        glVertex3f(-1, 1,-1 );
        glVertex3f( 1, 1,-1);
        glVertex3f( 1,-1,-1);
        glVertex3f(-1,-1,-1);

        glVertex3f( 1,-1,-1);
        glVertex3f( 1, 1,-1);
        glVertex3f( 1, 1, 1);
        glVertex3f( 1,-1, 1);

        glVertex3f(-1,-1, 1);
        glVertex3f(-1, 1, 1);
        glVertex3f(-1, 1,-1);
        glVertex3f(-1,-1,-1);

        glVertex3f(-1, 1,-1);
        glVertex3f(-1, 1, 1);
        glVertex3f( 1, 1, 1);
        glVertex3f( 1, 1,-1);

        glVertex3f( 1,-1,-1);
        glVertex3f( 1,-1, 1);
        glVertex3f(-1,-1, 1);
        glVertex3f(-1,-1,-1);

        glEnd();
    }

    void DrawArrow(Math::Vector3 dir){
        dir = Normalise(dir);
        dir = Math::ScalarProduct(dir, 2);

        glBegin(GL_LINES);
        glVertex3f( 0, 0, 0);
        glVertex3f( dir.x, dir.y, dir.z);
        glEnd();

        glPushMatrix();
        glTranslatef(dir.x, dir.y, dir.z);
        DrawCube(0.1);
        glPopMatrix();
    }
}
}
